-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove dependency from $NUPIC environment variable. Fixes numenta/nupic#1815, numenta/nupic#1947 #1970
Conversation
Oh oki :) so which approach shall we use now ? the #1968 one or this one ?and then we should close one PR and rather try to see if we can find all occurances and fix them with one approach :) |
Nice see new developers contributing.. 😃 |
👍 ...what @david-ragazzi said! |
Hi Pascals, From the current changes, I see that this PR doesn't remove $NUPIC but attenuate the occurence of |
@@ -19,3 +19,7 @@ | |||
# http://numenta.org/licenses/ | |||
# ---------------------------------------------------------------------- | |||
__version__ = "0.3.0.dev0" | |||
|
|||
import os | |||
NUPIC_ROOT = os.environ.get('NUPIC', os.path.dirname(os.path.realpath(__file__))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried get the absolute path of __file__
and so discard $NUPIC completely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi David, my change will consider $NUPIC
if it is set or get the path from __file__
as you suggested. I didn't remove $NUPIC
altogether because I wanted to avoid side-effects. If you guys are sure nobody relies on it, I'm more than happy to remove it for good. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's wait what Matthew thinks ;) keeping it might be better for sidemodules or community projects that may rely on it. There are a lot and Matthew probably has the best overview. How about just a try-except implementation?
@@ -19,3 +19,7 @@
http://numenta.org/licenses/
----------------------------------------------------------------------
version = "0.3.0.dev0"
+
+import os
+NUPIC_ROOT = os.environ.get('NUPIC', os.path.dirname(os.path.realpath(file)))
Hi David, my change will consider $NUPIC if it is set or consider the path from file as you suggested. I didn't remove $NUPIC altogether because I wanted to avoid side-effects. If you guys are sure nobody relies on it, I'm more than happy to remove it for good.
—
Reply to this email directly or view it on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You guys are right. We could keep $NUPIC as extra (but not required) variable. So this script should get the value of $NUPIC and in case of it is not found, get the absolute path of this __file__
..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether this is clear, but that's what it does right now. os.environ.get('NUPIC', 'foo')
will return either the value of $NUPIC
(if it's set) or 'foo'
. See https://docs.python.org/2/library/stdtypes.html#dict.get for reference.
So $NUPIC
ist completely optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'll stay with that solution?
#1968 now has the NUPIC removed entirely :D so however we decide its there ;) |
I like this. @scottpurdy what do you think? |
I think this is an improvement. In some cases (all?) we should use pkg_resources rather than paths relative to One thing that looks off is that the environment variable pointed to the root of the repository while the new logic sets Edit: It looks like most places were not updated so I won't keep commenting on all of the instances. One option would be to change |
@@ -58,7 +59,7 @@ | |||
'predictedField': 'field2', | |||
'predictionSteps': [1,3], | |||
|
|||
'dataSource': 'file://%s' % (os.path.join(os.environ['NUPIC'], 'examples', 'opf', | |||
'dataSource': 'file://%s' % (os.path.join(NUPIC_ROOT, 'examples', 'opf', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
examples
is in the root of the repo which is a level above NUPIC_ROOT
. And pkg_resources would probably be better here but up to you
@scottpurdy I have considered As for the log path in general, I agree that it shouldn't default to a directory relative to the package path. Thanks for your feedback, I will give those options a second thought. Do you have any suggestion what we should do about the logs? Maybe |
If the user doesn't specify a directory for logging then I don't think we should write to a file. I believe the default is to just write to console anyway. |
The major thing we need to decide now that #2006 is merged is: Will The other thing is whether to use |
I'm in favor of using pkg_resources whenever possible and only resort to NUPIC_ROOT when there's no other option. As for the other question, I think this is merely a matter of style. Are there any situations where we need to refer to the "actual root" directory? Otherwise we can safe ourselves some typing and have it point to root/nupic, maybe calling to NUPIC_SRC_ROOT to make this more obvious? |
If there is never a case where we need to refer to the repo root dir, I'm fine leaving it pointing to the |
@pehlert ping |
@rhyolight Sorry, I've been busy over the last week. I hope to be able to put some effort into this on Sunday. |
@pehlert ping 🍍 |
@pehlert ping again.. If you still are very busy, maybe @passiweinberger (if he doensn't mind) could incorporate your changes (cherry-picking them) in his PR (#1968) and these $NUPIC variable jobs are done. |
#2205 |
@pehlert I'm closing this PR because @passiweinberger incorporated your (nice) changes in #2205. Thanks! |
Yeah, you are right and see that you addressed well this in #2205. BTW we can close this because @scottpurdy can review the changes there. |
This is just a suggestion, but maybe it's at least able to point out the places where NuPIC still depends on the env variable
Fixes #1947
Blocked by #2006